package ru.server.example.handler;

import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Date: 2/19/11
 * Time: 11:27 PM
 *
 * @author Artem Titov
 */
public class SimpleHandler extends AbstractHandler {

    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        System.out.println(target);
        System.out.println("Simple asked!");
        final PrintWriter out = response.getWriter();
        response.setStatus(HttpServletResponse.SC_OK);
        out.print("Hello world");
        out.close();
    }

    /*@Override
    public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        System.out.println(target);
        System.out.println("simple");
        final PrintWriter out = response.getWriter();
        response.setStatus(HttpServletResponse.SC_OK);
        out.print("Hello world");
        out.close();
    }*/
}
